#include <allegro.h>

int main() 
{ 

SAMPLE *music;
int son_music ;
BITMAP *Buffer;
BITMAP *img0;
BITMAP *img1;
BITMAP *img2;
BITMAP *img3;
BITMAP *img4;
int menu=0;
int continuer=1 ;	

/* General initialization function */
allegro_init();
if(install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL)) {
allegro_message("Sound Error: %s", allegro_error);
return 1;
}
music=load_wav("/home/muerto/Bureau/music.wav");
if (!music) {
readkey();
return 0;
}
set_volume(255, 255);
son_music=play_sample(music,128,128,1000,0) ;
if (install_keyboard() == -1)
 {
allegro_message("Error! %s", allegro_error);
return -1;
}
set_color_depth(24);
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0) != 0) 
{
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); /* here’s the command for text mode */
allegro_message("Unable to initialize video mode!\n%s\n", allegro_error);
return 1;
}


while (!key[KEY_ESC])
{
Buffer = create_bitmap(800, 600);
img0=load_bitmap("/home/muerto/Bureau/img0.bmp", NULL);
img1=load_bitmap("/home/muerto/Bureau/img1.bmp", NULL);
img2=load_bitmap("/home/muerto/Bureau/img2.bmp", NULL);
img3=load_bitmap("/home/muerto/Bureau/img3.bmp", NULL);
img4=load_bitmap("/home/muerto/Bureau/img4.bmp", NULL);


blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
blit(img0, Buffer, 0, 0, 0, 0, img0->w, img0->h);
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);



while(continuer!=0)
{

if ((key[KEY_DOWN]) && (menu==0))
{
menu=1;
}
else if ((key[KEY_DOWN])  && (menu==1))
{
menu=2;
}
else if ((key[KEY_DOWN]) && (menu==2))
{
menu=3;
}
else if ((key[KEY_DOWN]) && (menu==3))
{
menu=4;
}
else if ((key[KEY_UP]) && (menu==3))
{
menu=2;
}
else if ((key[KEY_UP]) && (menu==2))
{
menu=1;
}
else if ((key[KEY_UP]) && (menu==1))
{
menu=0;
}
else if((key[KEY_UP]) && (menu==0))
{
menu=4;
}
else if((key[KEY_UP]) && (menu==4))
{
menu=3;
}
}
clear(Buffer);
if ( menu=0 )
{	
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);	
}
if ( menu==1 )
{	 
draw_sprite(Buffer,img1,600,800);	
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}
if ( menu==2 )
{	 
blit(img2, Buffer, 0, 0, 0, 0, img2->w, img2->h);	
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);	
}
if (menu==3)
{	 
blit(img3, Buffer, 0, 0, 0, 0, img3->w, img3->h);	
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}
if(menu==4)
{	 
blit(img4, Buffer, 0, 0, 0, 0, img4->w, img4->h);	
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);	
}	
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
clear(Buffer);
}

readkey();
destroy_bitmap(Buffer);
destroy_bitmap(screen);
return 0;
}


